<?php
class HCurrentPortalWidget implements IWidget {
	function render() {
		if (isset($_GET['portal_id']) && $_GET['portal_id'] != XPORTAL_ID) {
			HUtil::redirect(HCommon::PHPSELF());
		}
		// Processing			
		$a = HSql::fetch2Array(HSql::getData('portal_names'));				
		?>
		<select name="portal" onchange="gotoPortal(this.value)">			
			<?php
			for ($i = 0; $i < count($a); $i++) {
				$selected = '';				
				if (XPORTAL_ID == $a[$i]['id']) $selected = "selected = 'selected'";
			?>
			<option value="<?php echo $a[$i]['id']; ?>" <?php echo $selected;?>><?php echo $a[$i]['portal_name'];?></option>
			<?php
			}
			?>
		</select>
		<script>
			function gotoPortal(value) {
				window.location = 'index.php?portal_id='+value;
			}
		</script>
		<?php		
	}
}